package com.rgp.servicemap.controller;

import com.rgp.internalcommon.dto.AroundSearchDto;
import com.rgp.internalcommon.dto.ResponseResult;
import com.rgp.internalcommon.response.AroundSearchResponse;
import com.rgp.internalcommon.response.TerminalResponse;
import com.rgp.servicemap.service.TerminalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-19 18:13
 */
@RestController
public class TerminalController {

    @Autowired
    private TerminalService terminalService;

    /***
    * @description TODO
    * @param name 车牌号【作为终端的name】
    * @return com.rgp.internalcommon.dto.ResponseResult
    * @author nhp
    * @date  18:20
    */
    @PostMapping("terminal/add")
    public ResponseResult<TerminalResponse> addTerminal(@RequestParam("name") String name,@RequestParam("id")Long id){
        return terminalService.addTerminal(name,id);
    }

    @DeleteMapping("terminal/delete")
    public ResponseResult deleteTerminal(@RequestParam("tid") String tid){
        return terminalService.deleteTerminal(tid);
    }

    @GetMapping("terminal/list")
    public ResponseResult listTerminal(@RequestParam(value = "tid",required = false) String tid){
        return terminalService.listTerminal(tid);
    }

    @PostMapping("/terminal/aroundsearch")
    public ResponseResult<AroundSearchResponse[]> aroundSearch(@RequestBody AroundSearchDto aroundSearchDto){
        return terminalService.aroundSearch(aroundSearchDto);
    }
}